Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 3 - Finder Commands / Command Definitions


Get

The standard application command Get is a request to return the value of an object or objects. The Finder version of the Get command is similar to the standard application command, except that in most cases the Finder simply returns a reference to objects or objects requested. For properties that consist
of a value (such as the Name property) rather than a reference (such as the Desktop property of the Finder application), the Finder returns the value. In all cases, the Finder assigns the value returned to the predefined variable result.

SYNTAX
[ get ] referenceToObject [ as className ]
PARAMETERS
referenceToObject

A reference to an object whose value is to be returned in the result variable or a list of references.
Class: Reference or list of references
className
A class identifier that specifies the desired value class for
the returned data.
Class: Class identifier
Default value: The default value class for the object or objects
RESULT
A reference or list of references to the requested objects or, in the case of properties that consist of a value, a value of either the object's default value class or the class specified by the className parameter, or a list of values of that class. If the Finder can't return data in the value class specified by the className parameter, it generates an error.

If the referenceToObject parameter specifies a single object only (such as name of window 1), the result is a single value or reference. If the referenceToObject parameter refers to more than one object (such as items in startup disk), the result is a list of values or references. If the specified object doesn't exist, for example, if the reference is folder "My Folder" in startup disk and there is no folder of that name in the startup disk, the Finder generates an error.

EXAMPLES
This script returns the sizes, in bytes, of the folders at the top level of the startup disk:

tell application "Finder"   get size of folders in startup disk
end tell

--result: {27636, 1438359, 1774813}
This script returns a list of references to the folders at the top level of the startup disk:

tell application "Finder"   get folders in startup disk
end tell

--result: folder "Projects" of startup disk of 
application "Finder", folder "Financial" of startup disk of 
application "Finder", folder "Applications" of startup disk 
of application "Finder"
NOTES
The word get in the Get command is optional. For example, these statements are equivalent:

name of startup disk
get name of startup disk 

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996